package com.pig4cloud.pig.admin.api.resp;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class InfusionCoreStatisticsVO {
	// 今日输液总量
	private String totalInfusion;
	// 已输液
	private String finishInfusion;
	// 总袋数
	private String totalInfusionBag;
	// 现输液袋数
	private String finishInfusionBag;

	public InfusionCoreStatisticsVO(List<InfusionCoreStatisticsDTO> statisticsDTO) {
		BigDecimal totalInfusion = BigDecimal.ZERO;
		BigDecimal finishInfusion = BigDecimal.ZERO;
		BigDecimal totalInfusionBag = BigDecimal.ZERO;
		BigDecimal finishInfusionBag = BigDecimal.ZERO;
		if (statisticsDTO != null && !statisticsDTO.isEmpty()) {
			for (InfusionCoreStatisticsDTO infusionCoreStatisticsDTO : statisticsDTO) {
				totalInfusion = totalInfusion
						.add(infusionCoreStatisticsDTO.getSyal())
						.add(infusionCoreStatisticsDTO.getSybl())
						.add(infusionCoreStatisticsDTO.getSycl())
						.add(infusionCoreStatisticsDTO.getSydl())
						.add(infusionCoreStatisticsDTO.getSyel())
						.add(infusionCoreStatisticsDTO.getSyfl())
						.add(infusionCoreStatisticsDTO.getTssyal())
						.add(infusionCoreStatisticsDTO.getTssybl());
				totalInfusionBag = totalInfusionBag
						.add(infusionCoreStatisticsDTO.getSyaBag())
						.add(infusionCoreStatisticsDTO.getSybBag())
						.add(infusionCoreStatisticsDTO.getSycBag())
						.add(infusionCoreStatisticsDTO.getSydBag())
						.add(infusionCoreStatisticsDTO.getSyeBag())
						.add(infusionCoreStatisticsDTO.getSyfBag())
						.add(infusionCoreStatisticsDTO.getTssyaBag())
						.add(infusionCoreStatisticsDTO.getTssybBag());
				if (infusionCoreStatisticsDTO.getIsStart() == 1) {
					finishInfusion = finishInfusion
							.add(infusionCoreStatisticsDTO.getSyal())
							.add(infusionCoreStatisticsDTO.getSybl())
							.add(infusionCoreStatisticsDTO.getSycl())
							.add(infusionCoreStatisticsDTO.getSydl())
							.add(infusionCoreStatisticsDTO.getSyel())
							.add(infusionCoreStatisticsDTO.getSyfl())
							.add(infusionCoreStatisticsDTO.getTssyal())
							.add(infusionCoreStatisticsDTO.getTssybl());
					finishInfusionBag = finishInfusionBag
							.add(infusionCoreStatisticsDTO.getSyaBag())
							.add(infusionCoreStatisticsDTO.getSybBag())
							.add(infusionCoreStatisticsDTO.getSycBag())
							.add(infusionCoreStatisticsDTO.getSydBag())
							.add(infusionCoreStatisticsDTO.getSyeBag())
							.add(infusionCoreStatisticsDTO.getSyfBag())
							.add(infusionCoreStatisticsDTO.getTssyaBag())
							.add(infusionCoreStatisticsDTO.getTssybBag());
				}
			}
		}
		this.totalInfusion = totalInfusion.stripTrailingZeros().toPlainString();
		this.finishInfusion = finishInfusion.stripTrailingZeros().toPlainString();
		this.totalInfusionBag = totalInfusionBag.stripTrailingZeros().toPlainString();
		this.finishInfusionBag = finishInfusionBag.stripTrailingZeros().toPlainString();
	}
}
